import {observable, action} from 'mobx';

import { Toast, Tools } from 'weaver-mobile';

import {ListViewPage} from 'weaver-mobile-page';

import * as Api from '../../api/UserShareSetApi';

const getLabel = Tools.getLabel;

export default class UserShareSetStore {
  @observable isLoading = true;
  @observable defaultShareList = new ListViewPage.Store({ route: '/userCenter/shareSet', id: 'shareSet' });
  @observable myShareList = new ListViewPage.Store();
  @observable selectedTabIndex = 0;
  
   // 页面初始化数据
	@action
	initData() {
    this.getDefaultShareList();
    this.getMyShareList();
  }

  @action
  onTabChange = (index) => {
      this.selectedTabIndex = index;
  }

  //默认分享
  @action
  getDefaultShareList = (params = {}) => {
    Api.getDefaultShareList(params).then(res => {
      // const dataKey = res.datas;
      // if (dataKey) {
      //   this.dataKey = dataKey;
      //   this.defaultShareList.getData({ dataKey }, () => this.isLoading = false, true); // ture是否刷新用
      // }
      this.defaultShareList.getData({dataKey: res.datas});
      //this.defaultShareList.setState({data:{templateType:'strCol1'}});
    })
  };

  //我的分享
  @action
  getMyShareList = (params = {}) => {
    Api.getMyShareList(params).then(res => {
      this.myShareList.getData({dataKey: res.datas});
      //this.defaultShareList.setState({data:{templateType:'strCol1'}});
    })
  };
  
}